using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI.WebControls;

namespace Tool.BaseClass
{
	public class GClass37
	{
		public enum GEnum6
		{
			Name,
			Description
		}

		public static List<ListItem> smethod_0<TEnum>()
		{
			return GClass37.smethod_1<TEnum>(GClass37.GEnum6.Name);
		}

		public static List<ListItem> smethod_1<TEnum>(GClass37.GEnum6 genum6_0)
		{
			Type typeFromHandle = typeof(TEnum);
			List<ListItem> list = new List<ListItem>();
			if (typeFromHandle.IsEnum)
			{
				//switch (genum6_0)
				//{
				//case GClass37.GEnum6.Name:
				//	using (IEnumerator enumerator = Enum.GetValues(typeFromHandle).GetEnumerator())
				//	{
				//		while (enumerator.MoveNext())
				//		{
				//			int num = (int)enumerator.Current;
				//			list.Add(new ListItem(Enum.GetName(typeFromHandle, num), num.ToString()));
				//		}
				//		return list;
				//	}
				//	break;
				//case GClass37.GEnum6.Description:
				//	break;
				//default:
				//	return list;
				//}
				//foreach (int num in Enum.GetValues(typeFromHandle))
				//{
				//	string text = GClass37.smethod_2<TEnum>(num);
				//	list.Add(new ListItem(string.IsNullOrEmpty(text) ? Enum.GetName(typeFromHandle, num) : text, num.ToString()));
				//}
			}
			return list;
		}

		public static string smethod_2<TEnum>(int int_0)
		{
			Type typeFromHandle = typeof(TEnum);
			if (typeFromHandle.IsEnum)
			{
				string name = Enum.GetName(typeFromHandle, Convert.ToInt32(int_0));
				string result;
				if (name != null)
				{
					object[] customAttributes = typeFromHandle.GetField(name).GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
					if (customAttributes != null && customAttributes.Length != 0)
					{
						System.ComponentModel.DescriptionAttribute descriptionAttribute = customAttributes[0] as System.ComponentModel.DescriptionAttribute;
						result = descriptionAttribute.Description;
					}
					else
					{
						result = string.Empty;
					}
				}
				else
				{
					result = string.Empty;
				}
				return result;
			}
			throw new ArgumentException("不是枚举类型");
		}
	}
}
